<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Item extends BaseController
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model("Item_model",'item');
    }
    public function index(){
        $data = array();
        $_SESSION['menu'] = "item";
        $cat_id = $this->input->get('cat_id','');
        $filter = ['cat_id'=>$cat_id,'pinpai'=>1];
        $catList = $this->item->getCatList();
        $itemlist = $this->item->get_item_list($filter);
        foreach ($itemlist as $key => $value) {
             $itemlist[$key]['imageurl'] = $this->item->get_img_list_byid($value['id']);
        }
        $data=array(
            'item_list'=>$itemlist,
            'catList'=>$catList,
            'cat_id'=>$cat_id
        );
        $this->load->view('Item/index',$data);
    }

    public function themeHome(){
        $data = array();
        $_SESSION['menu'] = "themehome";
        $cat_id = $this->input->get('cat_id','');
        $filter = ['cat_id'=>$cat_id,'pinpai'=>2];
        $catList = $this->item->getCatList();
        $itemlist = $this->item->get_item_list($filter);
        foreach ($itemlist as $key => $value) {
             $itemlist[$key]['imageurl'] = $this->item->get_img_list_byid($value['id']);
        }
        $data=array(
            'item_list'=>$itemlist,
            'catList'=>$catList,
            'cat_id'=>$cat_id
        );
        $this->load->view('Item/themehome',$data);
    }

    public function detail(){
    	$_SESSION['menu'] = "item";
    	$this->load->view('Item/detail');
    }
}